<template>
  <div class="exhibits-content" :style="{ width: props.info.width + 'rem', height: props.info.height + 'rem' }">
    <div
      class="exhibits-item-parent"
      :class="{ 'item-parent-r': index % 2 !== 0 }"
      v-for="(item, index) in props.info.showpieceList"
      :key="index"
    >
      <div
        @contextmenu.stop="emit('onContextMenuChild', $event, index)"
        :style="{ 'background-image': `url(${publicUrls + 'free/style1/displayBoardStyle4Bg.webp'})` }"
        class="exhibits-item border-hover-style"
      >
        <img
          class="cover"
          v-lazy="getLinkUrl(item.coverUrl, '?imageView2/3/w/600/format/webp')"
          alt=""
          @click="viewImg(item.moduleId, item.id)"
        />
      </div>
      <img class="flower-btn" v-if="route.meta.loopType" v-lazy="publicUrls + 'free/style1/flower.png?imageView2/3/format/webp'" />
      <p class="items-title item-top">{{ item.name }}</p>
    </div>
  </div>
</template>

<script lang="ts">
export default defineComponent({
  name: 'style4',
});
</script>

<script setup lang="ts">
import { urls, getLinkUrl } from '@/utils/request/upload';
import { publicUrls } from '@/utils/minxin';
import { DraggableContainer } from 'vue3-draggable-resizable';
// import FlotMenu from '@/components/flotMenu/OutlineMenu.vue';
import ContextMenu from '@imengyu/vue3-context-menu';
import { getDraggableNumber, getExhibitsHeightRest, getdisabledY } from '@/utils/getRemComputed';
import { ref, reactive, watch, nextTick, defineComponent } from 'vue';
import { exbitMenuShow, exbitListMenuShow } from '@/hooks/menuHooks';
import { useProjectStore } from '@/store';
import { useRoute } from 'vue-router';

const emit = defineEmits([
  'emitChildItemDraggable',
  'emitChildItemDraggableStyle',
  'emitShowcaseDraggable',
  'emitShowcaseDraggableStyle',
  'onContextMenuChild',
]);
const store = useProjectStore();
const route = useRoute();
const contextMenuTrigger = ref(); //列表盒子dom
const parentLock = ref(true);
const childShow = ref(true);
const draggableResizable = ref(); //父级拖拽盒子ref
const timer = ref();
const ImgVisible = ref(false);
const ImgUrl = ref('');

const props = defineProps({
  width: {
    type: Number || String,
  },
  height: {
    type: Number || String,
  },
  indexs: {
    type: Number,
  },
  info: {
    type: Object,
  },
  childId: {
    type: Number,
  },
  AuxiliaryId: {
    type: Number,
  },
});
const emitChildItemDraggable = (draggingInfo: any, childIndex: number) => {
  emit('emitChildItemDraggable', draggingInfo, childIndex); //分组传递当前展品图距离相对父元素的xy偏移量变化
};
const emitChildItemDraggableStyle = (draggingInfo: any, childIndex: number) => {
  emit('emitChildItemDraggableStyle', draggingInfo, childIndex); //分组设置当前展品图距离相对父元素的宽高变化
};
const emitShowcaseDraggable = (draggingInfo: any) => {
  emit('emitShowcaseDraggable', draggingInfo); //传递当前展柜图距离相对父元素的xy偏移量变化
};
const emitShowcaseDraggableStyle = (draggingInfo: any) => {
  emit('emitShowcaseDraggableStyle', draggingInfo); //传递当前展柜距离相对父元素的宽高变化
};

const handleMouseDown = (event) => {
  event.stopPropagation();
};
const preventDefaultDrag = (event) => {
  event.stopPropagation();
};

const viewImg = (moduleId: number, e?: number) => {
  store.exhibitsModuleId = moduleId;
  store.exhibitsShowpieceid = e;
  store.exhibitsInfoShow = true;
};

// watch(
//   () => props.info.width,
//   () => {
//     childShow.value = false;
//     nextTick(() => {
//       childShow.value = true;
//     });
//   },
//   { deep: true },
// );
// watch(
//   () => props.in
// fo.height,
//   () => {
//     childShow.value = false;
//     nextTick(() => {
//       childShow.value = true;
//     });
//   },
//   { deep: true },
// );

//
</script>

<style lang="less" scoped>
.exhibits-content {
  position: relative;
  display: flex;
  z-index: 999;
  padding: 0px !important;
}

.active {
  :deep(.flot-menu) {
    display: flex;
  }
}
:deep(.active) {
  z-index: 999;
}
:deep(.vdr-handle) {
  z-index: 66;
}
.items-title {
  text-align: center;
  width: 251px;
  height: 38px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: SourceHanSerifCN-Bold;
  font-size: 16px;
  line-height: 38px;
  color: #fef3df;
  margin-top: 20px;
  padding-left: 14px;
  padding-right: 14px;
  background: url(https://static.jiyi.show/free/style1/displayBoardStyle4TitleBg.webp) no-repeat center/100% 100%;
}

.item-top {
  -webkit-box-reflect: below 1000% linear-gradient(rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0.15));
}
.exhibits-item-parent {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 400px;
  margin: 0 25px;
  position: relative;

  &:hover > .flower-btn {
    display: none;
  }
}
.item-parent-r {
  margin-top: 103px;
  .items-title {
    margin-bottom: 20px;
  }
  .flower-btn {
    top: 55%;
  }
}
.exhibits-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 400px;
  height: 368px;
  background-size: contain !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  flex-shrink: 0;
  -webkit-box-reflect: below 100% linear-gradient(transparent, rgba(0, 0, 0, 0.15));
  padding-bottom: 6px;
  padding-right: 2px;
  &:nth-child(even) {
    -webkit-box-reflect: below 80% linear-gradient(transparent, rgba(0, 0, 0, 0.15));
  }
}
.flower-btn {
  width: 40px;
  height: 40px;
  object-fit: cover;
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -30%);
  animation: flower 2s linear infinite;
  @keyframes flower {
    0% {
      opacity: 0;
    }
    40% {
      opacity: 100%;
    }
    80% {
      opacity: 100%;
    }
    100% {
      opacity: 0;
    }
  }
}
.cover {
  width: 351px;
  height: 256px;
  object-fit: contain;
}
</style>
